<template>
<d-loading />
</template>

<script setup lang="ts">
import {PM_ROUTE_PATH, usePmAppStore} from "@/stores/pm";
import {gotoH5PasskeyLogin} from "@/interceptors/route";
import {PmTabBarType} from "@/enum";

function loginFn() {
  // const code = query.code;
  // const type = query.type;
  // usePmAppStore().login({
  //   code: code,
  //   type: type,
  // })
}

onLoad((query) => {
  const accessToken = query['access_token'];
  const refreshToken = query['refresh_token'];
  if (accessToken) {
    usePmAppStore().setToken(accessToken);
    usePmAppStore().setRefreshToken(refreshToken);
    usePmAppStore().setTabKey(PmTabBarType.PROJECT);
    uni.redirectTo({ url: `${PM_ROUTE_PATH}/index/index` })
    // if (usePmAppStore().loginRedirectUrl) {
    //   uni.redirectTo({ url: usePmAppStore().loginRedirectUrl })
    //   usePmAppStore().setLoginRedirectUrl(null);
    // } else {
    //   uni.redirectTo({ url: `${PM_ROUTE_PATH}/index/index` })
    // }
  } else {
    gotoH5PasskeyLogin();
  }
  // usePmAppStore().login().then(() => {
  //   uni.redirectTo({ url: usePmAppStore().loginRedirectUrl })
  // })
})
</script>

<style scoped lang="scss">

</style>
